Skip to content

test: improve flaky usb reconnection test#2332

Open
yaroslavborbat wants to merge 1 commit intomainfrom
test/fix-usb
Open

test: improve flaky usb reconnection test#2332
yaroslavborbat wants to merge 1 commit intomainfrom
test/fix-usb

Conversation

@yaroslavborbat
Copy link
Copy Markdown
Member

@yaroslavborbat yaroslavborbat commented May 8, 2026

Description

Refactor the flaky USB reconnection e2e test to improve reliability.

The monolithic mountUSB() function was split into three focused steps:

  • findUSBMountDevice() — locates the block device path via /sys/bus/usb/devices with retries
  • formatUSBDevice(mountDevice) — formats the device with mkfs.vfat before the first mount to ensure a clean filesystem
  • mountUSBDevice(mountDevice) — mounts the located device directly by path (no multi-fallback mount -t auto)

Additional diagnostic GinkgoWriter.Println calls were added at key steps, and LongTimeout is now used for the mount step to handle slow environments.

Why do we need it, and what problem does it solve?

The USB reconnection test was flaky because:

  1. Device lookup and mounting were bundled in one shell script, making it hard to diagnose which step failed.
  2. The mount command tried several fallback options (-t auto, -t vfat, no flag), masking root causes.
  3. The device was not formatted before mounting, so an unclean or unformatted device could cause a mount failure on first use.

Splitting the steps, adding an explicit mkfs.vfat format, and increasing the mount timeout makes the test deterministic and easier to debug when it does fail.

What is the expected result?

  1. Run the VirtualMachineUSB e2e suite.
  2. The test should consistently pass without flaky failures on the "Mounting USB device" and "Remounting USB device after migration" steps.
  3. On failure, GinkgoWriter output clearly shows which step (find / format / mount) failed.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: test
type: fix
summary: Improve reliability of flaky USB reconnection e2e test by splitting mount logic into find, format, and mount steps.
impact_level: low

Signed-off-by: Yaroslav Borbat <yaroslav.borbat@flant.com>
@yaroslavborbat yaroslavborbat requested a review from Isteb4k as a code owner May 8, 2026 09:29
@yaroslavborbat yaroslavborbat requested review from danilrwx and hardcoretime and removed request for Isteb4k May 8, 2026 09:29
@yaroslavborbat yaroslavborbat added this to the v1.9.0 milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant